import Router from '@koa/router';
import * as logController from '../controllers/log.controller';
import { authMiddleware, adminMiddleware } from '../middleware/auth';

const router = new Router({
  prefix: '/api/logs',
});

// 所有路由都需要认证和管理员权限
router.use(authMiddleware);
router.use(adminMiddleware);

// 查询日志列表
router.post('/list', logController.getLogList);

// 查询日志详情
router.post('/detail', logController.getLogDetail);

// 删除旧日志
router.post('/delete-old', logController.deleteOldLogs);

// 获取日志统计
router.post('/stats', logController.getLogStats);

// 筛选异常请求
router.post('/abnormal', logController.getAbnormalRequests);

export default router;

